<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%-- petr0 25.09.12 21:49 --%>
<form:form method="POST" modelAttribute="realty">
    <table>
        <tr>
            <td><label for="createDate">Дата добавления</label></td>
            <td>
                <%-- на сервер не уходит --%>
                <c:choose>
                    <c:when test="${not empty realty.createDate}">
                        <form:input path="createDate.time" id="createDate" disabled="true"/>
                    </c:when>
                    <c:otherwise>
                        <jsp:useBean id="now" class="java.util.Date"/>
                        <fmt:formatDate value="${now}" pattern="dd.MM.yyyy HH:mm:ss" var="nowFormatted"/>
                        <input type="text" id="createDate" value="${nowFormatted}" disabled="disabled"/>
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
        <tr>
            <td><label for="phone">Телефон</label></td>
            <td><form:input path="phone" id="phone"/></td>
            <td><form:errors path="phone" cssClass="error"/></td>
        </tr>
        <tr>
            <td><label for="fio">ФИО</label></td>
            <td><form:input path="fio" id="fio"/></td>
            <td><form:errors path="fio" cssClass="error"/></td>
        </tr>
        <tr>
            <td><label for="address">Адрес</label></td>
            <td><form:input path="address" id="address"/></td>
            <td><form:errors path="address" cssClass="error"/></td>
        </tr>
        <tr>
            <td><label for="rooms">Комнат</label></td>
            <td><form:input path="rooms" id="rooms"/></td>
            <td><form:errors path="rooms" cssClass="error"/></td>
        </tr>
        <tr>
            <td><label for="description">Описание</label></td>
            <td><form:input path="description" id="description"/></td>
            <td><form:errors path="description" cssClass="error"/></td>
        </tr>
        <tr>
            <td><label for="comment">Комментарий</label></td>
            <td><form:input path="comment" id="comment"/></td>
            <td><form:errors path="comment" cssClass="error"/></td>
        </tr>
    </table>
    <input type="submit" value="Сохранить"/>
    <a href="/realty">Отмена</a>
</form:form>

